<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("components4phpfull/jtgroupbox.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class CompanyReminders extends Page
{
       public $Image3 = null;
       public $edAssetDescription = null;
       public $btnCancel = null;
       public $btnSubmit = null;
       public $lblAssetDescription = null;
       public $edAssetIdentifiers = null;
       public $lblAssetIdentifiers = null;
       public $edMessageLine2 = null;
       public $lblMessageLine2 = null;
       public $edMessageLine1 = null;
       public $lblMessageLine1 = null;
       public $edSubjectLine = null;
       public $lblSubjectLine = null;
       public $JTGroupEmailAlert = null;
       public $chkWrite = null;
       public $chkCopy = null;
       public $JTGroupReminderOptions = null;
       public $JTSiteTheme1 = null;
       function btnCancelClick($sender, $params)
       {
       redirect('vehicle_list.php?company_id='.$_SESSION['company_id']);
       }


       function btnSubmitClick($sender, $params)
       {

       if ($this->chkCopy->Checked==true)
       {
       $chkCopy ='1';
       }
       else
       {
       $chkCopy='0';
       }

       if ($this->chkWrite->Checked==true)
       {
       $chkWrite ='1';
       }
       else
       {
       $chkWrite ='0';
       }

       $result=mysql_query("select * from company_reminders_tbl where company_id='".$_SESSION['company_id']."'");
       $count=mysql_num_rows($result);
       if($count==0)
       {
       mysql_query("insert into company_reminders_tbl (company_id,
       copy_reminder,
       write_completion,
       subject_line,
       message_line1,
       message_line2,
       asset_identifiers,
       asset_description)

       Values('".$_SESSION['company_id']."',
       '".$chkCopy."',
       '".$chkWrite."',
       '".$this->edSubjectLine->Text."',
       '".$this->edMessageLine1->Text."',
       '".$this->edMessageLine2->Text."',
       '".$this->edAssetIdentifiers->Text."',
       '".$this->edAssetDescription->Text."')") or die ("insert reminders - " . mysql_error());
       }
       else
       {
       mysql_query("update company_reminders_tbl set
       copy_reminder='".$chkCopy."',
       write_completion='".$chkWrite."',
       subject_line='".$this->edSubjectLine->Text."',
       message_line1='".$this->edMessageLine1->Text."',
       message_line2='".$this->edMessageLine2->Text."',
       asset_identifiers='".$this->edAssetIdentifiers->Text."',
       asset_description='".$this->edAssetDescription->Text."'
       where company_id='".$_SESSION['company_id']."'") or die ("update reminders - " . mysql_error());
       }
       redirect('vehicle_list.php?company_id='.$_SESSION['company_id']);


       }

       function CompanyRemindersCreate($sender, $params)
       {

       $query = "select * from company_reminders_tbl where company_id='".$_SESSION['company_id']."'";
       $result_show = mysql_query($query)or die("SELECT TIRES - " . mysql_error());
       $row= mysql_fetch_array($result_show);

      if($row['copy_reminder']=='1')
      {
      $this->chkCopy->Checked=true;
      }
      else
      {
      $this->chkCopy->Checked=false;
      }

      if($row['write_completion']=='1')
      {
      $this->chkWrite->Checked=true;
      }
      else
      {
      $this->chkWrite->Checked=false;
      }

       $this->edSubjectLine->Text = $row['subject_line'];
       $this->edMessageLine1->Text = $row['message_line2'];
       $this->edMessageLine2->Text = $row['message_line2'];
       $this->edAssetIdentifiers->Text = $row['asset_identifiers'];
       $this->edAssetDescription->Text = $row['asset_description'];
       }



}

global $application;

global $CompanyReminders;

//Creates the form
$CompanyReminders=new CompanyReminders($application);

//Read from resource file
$CompanyReminders->loadResource(__FILE__);

//Shows the form
$CompanyReminders->show();

?>